package regex;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author chen
 */
class Graptools{
static int[] get_intarray_from_GraphString(String str,String startChar)
{
    String regEx = "\\A"+startChar+"[\\d"+"[\\s,|;:\\t]*]+"+"\\z";
    Pattern pattern = Pattern.compile(regEx);
    Matcher matcher = pattern.matcher(str);
    int[] res=null;
    if(matcher.matches()){
   Matcher m=Pattern.compile("\\d+").matcher(str);
   try{
   try(PipedOutputStream tar=new PipedOutputStream();
       DataOutputStream out_data=new DataOutputStream(tar);
       PipedInputStream source=new PipedInputStream();
       DataInputStream in_data=new DataInputStream(source);)
   {  //very importent
       tar.connect(source);
       
      int count=0;     
      while(m.find()) 
      { 
          out_data.writeInt(Integer.parseInt(m.group()));
          count++;
      }
      res=new int[count];
      int cur=0;
      while(cur<count)
      {
          res[cur]=in_data.readInt();
          cur++;
      }
     }
     }catch(IOException e){}
    }
    return res;
  }
}
